#pragma once

#include <BaseTsd.h>
#include <cmath>
#include <vector>
#include <fstream>
#include <iostream>
#include <utility>

using std::vector;
using std::ostream;

typedef double TIME;
typedef unsigned long _PIXEL;									// Pixel
typedef float FLOAT;											// For dimensions/position
#define _PI	3.1415926f											// Value of PI
#define _BITS_PER_PIXEL	32										// Color depth
#define _BYTES_PER_PIXEL _BITS_PER_PIXEL >> 3
#define _RGB(r,g,b)	(((r) << 16) | ((g) << 8) | (b))			// Convert to RGB

class VECTOR_4
{
public:
	FLOAT x,y,z,w;
	
	FLOAT& operator[] (UINT32 index) {return (&x)[index];}
	const VECTOR_4& operator= (FLOAT* pVecArray) {x=pVecArray[0];y=pVecArray[1];z=pVecArray[2];w=pVecArray[3];return *this;}
	VECTOR_4& operator+ (const VECTOR_4& vOther) {x+=vOther.x; y+=vOther.y; z+=vOther.z;return *this;}
	VECTOR_4& operator* (FLOAT value) {x*=value;y*=value;z*=value;return *this;}
	VECTOR_4& normalize() {FLOAT norm=1/sqrt(x*x+y*y+z*z);x*=norm;y*=norm;z*=norm;return *this;}
	FLOAT length() {return sqrt(x*x+y*y+z*z);}
	FLOAT length_2() {return x*x+y*y+z*z;}
};
inline ostream& operator << (ostream &oStream, const VECTOR_4 & vec) 
{oStream << "[ " << vec.x << ", " << vec.y << ", " << vec.z << ", " << vec.w << " ]"; return oStream; }

typedef vector<VECTOR_4> VEC4ARRAY;

class VECTOR_3
{
	FLOAT x,y,z;
};